<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="google-site-verification" content="VGgQeH6NiuAKspyCFT7dqUNmNhg6RJoMYQXErdy0jgE" />
  <meta name="baidu-site-verification" content="code-yNmdsKJ9GP" />
  
  
  <meta name="keywords" content="Elasticsearch,elasticsearch,搭建，环境搭建,">
  
  
  <meta name="description" content="Elasticsearch 环境搭建">
  
  <title>
    4. Elasticsearch Mapping和Template操作 |
    
    思远程序
  </title>
  <!-- Icon -->
  
    <link rel="shortcut icon" href="/favicon.ico">
    
  
<link rel="stylesheet" href="/css/style.css">

  
  
<link rel="stylesheet" href="/fancybox/jquery.fancybox.min.css">

  
  
<script src="/js/pace.min.js"></script>

<meta name="generator" content="Hexo 6.2.0"></head>

<body>
  <main class="content">
    <section class="outer">
  <article id="post-4. Elasticsearch Mapping和Template操作" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
      

<h1 class="article-title" itemprop="name">
  4. Elasticsearch Mapping和Template操作
</h1>



    </header>
    

    
    <div class="article-meta">
      <a href="/2022/07/23/4.%20Elasticsearch%20Mapping%E5%92%8CTemplate%E6%93%8D%E4%BD%9C/" class="article-date">
  <time datetime="2022-07-23T05:00:00.000Z" itemprop="datePublished">2022-07-23</time>
</a>
      
<div class="article-category">
  <a class="article-category-link" href="/categories/%E5%88%86%E5%B8%83%E5%BC%8F%E6%A1%86%E6%9E%B6/">分布式框架</a>
</div>

    </div>
    

    
    
<div class="tocbot"></div>

    

    <div class="article-entry" itemprop="articleBody">
      
      
      
      <h3 id="倒排索引"><a href="#倒排索引" class="headerlink" title="倒排索引"></a>倒排索引</h3><p>当数据写入 ES 时，数据将会通过 分词 被切分为不同的 term，ES 将 term 与其对应的文 档列表建立一种映射关系，这种结构就是 倒排索引。如下图所示:<br><img src="https://cdn.nlark.com/yuque/0/2022/png/1445568/1657111951023-9c881dbc-b3a1-4808-9bf7-13a0a381738d.png#clientId=ue5c47b60-ee4c-4&crop=0&crop=0.0104&crop=1&crop=1&from=paste&height=323&id=ucf919c14&margin=%5Bobject%20Object%5D&name=image.png&originHeight=646&originWidth=1676&originalType=binary&ratio=1&rotation=0&showTitle=false&size=486974&status=done&style=stroke&taskId=u8eed8e52-0d31-4d9d-8816-afcb08a78b5&title=&width=838" alt="image.png"></p>
<span id="more"></span>

<p>为了进一步提升索引的效率，ES 在 term 的基础上利用 term 的前缀或者后缀构建了 term index, 用于对 term 本身进行索引，ES 实际的索引结构如下图所示：<br><img src="https://cdn.nlark.com/yuque/0/2022/png/1445568/1657112040855-2995b644-50c6-429d-bb21-fd74aa3ca9f2.png#clientId=ue5c47b60-ee4c-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=407&id=ue3da8dfc&margin=%5Bobject%20Object%5D&name=image.png&originHeight=814&originWidth=1722&originalType=binary&ratio=1&rotation=0&showTitle=false&size=933145&status=done&style=stroke&taskId=u78582b03-beaf-4562-9702-6801fbda172&title=&width=861" alt="image.png"><br>这样当我们去搜索某个关键词时，ES 首先根据它的前缀或者后缀迅速缩小关键词的在 term dictionary 中的范围，大大减少了磁盘IO的次数。 </p>
<ul>
<li>单词词典(Term Dictionary) :记录所有文档的单词，记录单词到倒排列表的 关联关系；<ul>
<li>常用字典数据结构: <a target="_blank" rel="noopener" href="https://www.cnblogs.com/LBSer/p/4119841.html">https://www.cnblogs.com/LBSer/p/4119841.html</a></li>
</ul>
</li>
<li>倒排列表(Posting List)-记录了单词对应的文档结合，由倒排索引项组成；</li>
<li>倒排索引项(Posting)：<ul>
<li>文档ID ；</li>
<li>词频TF–该单词在文档中出现的次数，用于相关性评分；</li>
<li>位置(Position)-单词在文档中分词的位置。用于短语搜索 (match phrase query) ；</li>
<li>偏移(Offset)-记录单词的开始结束位置，实现高亮显示；</li>
</ul>
</li>
</ul>
<p>Elasticsearch 的JSON文档中的每个字段，都有自己的倒排索引。<br>可以指定对某些字段不做索引：</p>
<ul>
<li>优点：节省存储空间；</li>
<li>缺点：字段无法被搜索；</li>
</ul>
<h3 id="文档映射-Mapping"><a href="#文档映射-Mapping" class="headerlink" title="文档映射 Mapping"></a>文档映射 Mapping</h3><p>Mapping类似数据库中的schema的定义，作用如下: </p>
<ul>
<li>定义索引中的字段的名称；</li>
<li>定义字段的数据类型，例如字符串，数字，布尔等；</li>
<li>字段，倒排索引的相关配置(Analyzer) ；</li>
</ul>
<p>ES中Mapping映射可以分为动态映射和静态映射。 			</p>
<h4 id="动态映射"><a href="#动态映射" class="headerlink" title="动态映射:"></a>动态映射:</h4><p>在关系数据库中，需要事先创建数据库，然后在该数据库下创建数据表，并创建表字段、类 型、长度、主键等，最后才能基于表插入数据。而Elasticsearch中不需要定义Mapping映 射(即关系型数据库的表、字段等)，在文档写入Elasticsearch时，会根据文档字段自动识别类型，这种机制称之为动态映射。</p>
<h4 id="静态映射"><a href="#静态映射" class="headerlink" title="静态映射:"></a>静态映射:</h4><p>静态映射是在Elasticsearch中也可以事先定义好映射，包含文档的各字段类型、分词器 等，这种方式称之为静态映射。 					 					<br>动态映射(Dynamic Mapping)的机制，使得我们无需手动定义Mappings， Elasticsearch会自动根据文档信息，推算出字段的类型。但是有时候会推算的不对，例如地 理位置信息。当类型如果设置不对时，会导致一些功能无法正常运行，例如Range查询 </p>
<table>
<thead>
<tr>
<th>字段类型</th>
<th>ES 类型</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>string、varchar、text</td>
<td>text</td>
<td>用于全文索引，该类型的字段将通过分词器进行分词，最终用于构建索引</td>
</tr>
<tr>
<td>string、varchar</td>
<td>keyword</td>
<td>不分词，适合<strong>简短、结构化字符串</strong>，例如<strong>主机名、姓名、商品名称</strong>等，可以用于过滤、排序、聚合检索，也可以用于<strong>精确查询</strong>。</td>
</tr>
<tr>
<td>long</td>
<td>long</td>
<td>有符号64-bit integer：-2^63 ~ 2^63 - 1</td>
</tr>
<tr>
<td>integer</td>
<td>integer</td>
<td>有符号32-bit integer，-2^31 ~ 2^31 - 1</td>
</tr>
<tr>
<td></td>
<td>short</td>
<td>有符号16-bit integer，-32768 ~ 32767</td>
</tr>
<tr>
<td></td>
<td>byte</td>
<td>有符号8-bit integer，-128 ~ 127</td>
</tr>
<tr>
<td>double</td>
<td>double</td>
<td>64-bit IEEE 754 浮点数</td>
</tr>
<tr>
<td>float</td>
<td>float</td>
<td>32-bit IEEE 754 浮点数</td>
</tr>
<tr>
<td></td>
<td>half_float</td>
<td>16-bit IEEE 754 浮点数</td>
</tr>
<tr>
<td>boolean</td>
<td>boolean</td>
<td>true,false</td>
</tr>
<tr>
<td>date</td>
<td>date</td>
<td>日期类型：2013-12-25、2013-12-25 T22:21:20</td>
</tr>
<tr>
<td>bytes&#x2F;binary</td>
<td>binary</td>
<td>该类型的字段把值当做经过 base64 编码的字符串，默认不存储，且不可搜索</td>
</tr>
</tbody></table>
<p><img src="https://cdn.nlark.com/yuque/0/2022/png/1445568/1657112793031-51f4b108-6d07-472d-acdb-84f1df9f6ac2.png#clientId=ue5c47b60-ee4c-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=587&id=ua01b6226&margin=%5Bobject%20Object%5D&name=image.png&originHeight=1174&originWidth=2736&originalType=binary&ratio=1&rotation=0&showTitle=false&size=588082&status=done&style=stroke&taskId=u34376081-448b-4244-94a9-b5c296da26d&title=&width=1368" alt="image.png"></p>
<h4 id="dynamic-配置"><a href="#dynamic-配置" class="headerlink" title="dynamic 配置"></a>dynamic 配置</h4><p>思考：如上案例能否后期更改Mapping的字段类型?<br>两种情况: </p>
<ul>
<li>新增加字段 <ul>
<li>dynamic设为true时，一旦有新增字段的文档写入，Mapping 也同时被更新；</li>
<li>dynamic设为false，Mapping 不会被更新，新增字段的数据 无法被索引，但是信息会出现在_source中；</li>
<li>dynamic设置成strict(严格控制策略)，文档写入失败，抛出异常；</li>
</ul>
</li>
</ul>
<p><img src="https://cdn.nlark.com/yuque/0/2022/png/1445568/1657112891967-9d92a6b9-c13a-45e3-9d80-fe15959752f4.png#clientId=ue5c47b60-ee4c-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=228&id=ufcf0c6d8&margin=%5Bobject%20Object%5D&name=image.png&originHeight=456&originWidth=1682&originalType=binary&ratio=1&rotation=0&showTitle=false&size=45619&status=done&style=stroke&taskId=uc0b1f217-ddf5-45d4-ade9-17bd973af59&title=&width=841" alt="image.png"></p>
<ul>
<li>对已有字段，一旦已经有数据写入，就不再支持修改字段定义<ul>
<li>Lucene 实现的倒排索引，一旦生成后，就不允许修改；</li>
<li>如果希望改变字段类型，可以利用 reindex API，重建索引；</li>
</ul>
</li>
</ul>
<p>					</p>
<p>原因:      </p>
<ul>
<li>如果修改了字段的数据类型，会导致已被索引的数据无法被搜索；</li>
<li>但是如果是增加新的字段，就不会有这样的影响 <figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"># 删除所有</span><br><span class="line">DELETE /user</span><br><span class="line"># 文档映射</span><br><span class="line">PUT /user</span><br><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;mappings&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;dynamic&quot;</span><span class="punctuation">:</span> <span class="string">&quot;strict&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;properties&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">      <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">        <span class="attr">&quot;type&quot;</span><span class="punctuation">:</span> <span class="string">&quot;text&quot;</span></span><br><span class="line">      <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">&quot;address&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">        <span class="attr">&quot;type&quot;</span><span class="punctuation">:</span> <span class="string">&quot;object&quot;</span><span class="punctuation">,</span></span><br><span class="line">        <span class="attr">&quot;dynamic&quot;</span><span class="punctuation">:</span> <span class="string">&quot;true&quot;</span></span><br><span class="line">      <span class="punctuation">&#125;</span></span><br><span class="line">    <span class="punctuation">&#125;</span></span><br><span class="line">  <span class="punctuation">&#125;</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br><span class="line"># 插入文档报错，原因新增 age 字段，会抛出异常</span><br><span class="line">PUT /user/_doc/<span class="number">1</span></span><br><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="string">&quot;fox&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;age&quot;</span><span class="punctuation">:</span> <span class="number">30</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;address&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;province&quot;</span><span class="punctuation">:</span> <span class="string">&quot;湖南&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;city&quot;</span><span class="punctuation">:</span> <span class="string">&quot;长沙&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br></pre></td></tr></table></figure>
<img src="https://cdn.nlark.com/yuque/0/2022/png/1445568/1657113285502-881dcd45-9e2e-4d35-ae68-23783523e4ae.png#clientId=ue5c47b60-ee4c-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=307&id=u7fa50770&margin=%5Bobject%20Object%5D&name=image.png&originHeight=614&originWidth=2740&originalType=binary&ratio=1&rotation=0&showTitle=false&size=154789&status=done&style=stroke&taskId=u258ff06b-0c47-45c9-b9e4-00b49c4cbfa&title=&width=1370" alt="image.png"><br>修改 dynamic:true 后再次插入文档成功 <figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">PUT /user/_mapping</span><br><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;dynamic&quot;</span><span class="punctuation">:</span> <span class="keyword">true</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br><span class="line"></span><br><span class="line">PUT /user/_doc/<span class="number">1</span></span><br><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="string">&quot;fox&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;age&quot;</span><span class="punctuation">:</span> <span class="number">30</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;address&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;province&quot;</span><span class="punctuation">:</span> <span class="string">&quot;湖南&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;city&quot;</span><span class="punctuation">:</span> <span class="string">&quot;长沙&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br><span class="line"></span><br><span class="line">GET /user/_doc/<span class="number">1</span></span><br></pre></td></tr></table></figure></li>
</ul>
<h4 id="对已有字段的mapping修改"><a href="#对已有字段的mapping修改" class="headerlink" title="对已有字段的mapping修改"></a>对已有字段的mapping修改</h4><p>具体方法: </p>
<ol>
<li>如果要推倒现有的映射, 你得重新建立一个静态索引；</li>
<li>然后把之前索引里的数据导入到新的索引里；</li>
<li>删除原创建的索引；</li>
<li>为新索引起个别名, 为原索引名(这样原先使用的索引就不需要更改了，可以使用别名搜索)；<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br></pre></td><td class="code"><pre><span class="line"># 新建索引 user</span><br><span class="line">PUT /user</span><br><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;mappings&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;properties&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">      <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">        <span class="attr">&quot;type&quot;</span><span class="punctuation">:</span> <span class="string">&quot;text&quot;</span></span><br><span class="line">      <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">&quot;address&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">        <span class="attr">&quot;type&quot;</span><span class="punctuation">:</span> <span class="string">&quot;text&quot;</span></span><br><span class="line">      <span class="punctuation">&#125;</span></span><br><span class="line">    <span class="punctuation">&#125;</span></span><br><span class="line">  <span class="punctuation">&#125;</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br><span class="line"># 插入文档</span><br><span class="line">PUT /user/_doc/<span class="number">1</span></span><br><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="string">&quot;fox&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;age&quot;</span><span class="punctuation">:</span> <span class="number">30</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;address&quot;</span><span class="punctuation">:</span> <span class="string">&quot;湖南长沙&quot;</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br><span class="line"></span><br><span class="line">GET /user/_doc/<span class="number">1</span></span><br><span class="line"># 新建文档<span class="number">2</span></span><br><span class="line">PUT /user2</span><br><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;mappings&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;properties&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">      <span class="attr">&quot;name&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">        <span class="attr">&quot;type&quot;</span><span class="punctuation">:</span> <span class="string">&quot;text&quot;</span></span><br><span class="line">      <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">&quot;address&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">        <span class="attr">&quot;type&quot;</span><span class="punctuation">:</span> <span class="string">&quot;text&quot;</span><span class="punctuation">,</span></span><br><span class="line">        <span class="attr">&quot;analyzer&quot;</span><span class="punctuation">:</span> <span class="string">&quot;ik_max_word&quot;</span></span><br><span class="line">      <span class="punctuation">&#125;</span></span><br><span class="line">    <span class="punctuation">&#125;</span></span><br><span class="line">  <span class="punctuation">&#125;</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br><span class="line"># 数据迁移 user -&gt; user2</span><br><span class="line">POST _reindex</span><br><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;source&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;index&quot;</span><span class="punctuation">:</span> <span class="string">&quot;user&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;dest&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;index&quot;</span><span class="punctuation">:</span> <span class="string">&quot;user2&quot;</span></span><br><span class="line">  <span class="punctuation">&#125;</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br><span class="line"></span><br><span class="line">GET /user/_doc/<span class="number">1</span></span><br><span class="line"></span><br><span class="line">GET /user2/_doc/<span class="number">1</span></span><br><span class="line"></span><br><span class="line">DELETE /user</span><br><span class="line"># 设置别名</span><br><span class="line">PUT /user2/_alias/user</span><br><span class="line"></span><br><span class="line">GET /user</span><br></pre></td></tr></table></figure></li>
</ol>
<pre><code>   			
     
  
         
     
  
</code></pre>

      
    </div>
    <footer class="article-footer">
      <a data-url="https://siyit.gitee.io/2022/07/23/4.%20Elasticsearch%20Mapping%E5%92%8CTemplate%E6%93%8D%E4%BD%9C/" data-id="cl6bukbt7000psu6f7zls5tfj" class="article-share-link">
        分享
      </a>
      
<ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Elasticsearch/" rel="tag">Elasticsearch</a></li></ul>

    </footer>

  </div>

  
  
<nav class="article-nav">
  
  <a href="/2022/07/23/5.%20Elasticsearch%20%E9%AB%98%E7%BA%A7%E6%9F%A5%E8%AF%A2/" class="article-nav-link">
    <strong class="article-nav-caption">前一篇</strong>
    <div class="article-nav-title">
      
      5. Elasticsearch 高级查询
      
    </div>
  </a>
  
  
  <a href="/2022/07/23/3.%20Elasticsearch%20%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C/" class="article-nav-link">
    <strong class="article-nav-caption">后一篇</strong>
    <div class="article-nav-title">3.Elasticsearch 基本操作</div>
  </a>
  
</nav>

  

  
  
<div class="vcomments" id="vcomments"></div>

<script src="https://unpkg.com/valine/dist/Valine.min.js"></script>

<script>
  new Valine({
    el: '#vcomments',
    appId: 'A7Ny5JW4l2XoShLWoQfpND2b-gzGzoHsz',
    appKey: 'lTbAjSoXEDQETkbAcE4zpYpu',
    notify: 'true',
    verify: 'true',
    avatar: 'identicon',
    pageSize: '10',
    placeholder: '请输入...'
  })
</script>

  
  

</article>
</section>
    <footer class="footer">
  <div class="outer">
    <div class="float-right">
      <ul class="list-inline">
  
  <li><i class="fe fe-smile-alt"></i> <span id="busuanzi_value_site_uv"></span></li>
  
  <li><i class="fe fe-bookmark"></i> <span id="busuanzi_value_page_pv"></span></li>
  
</ul>
    </div>
    <ul class="list-inline">
      <li>思远程序 &copy; 2022</li>
      
        <li></li>
      
      <li>Powered by <a href="http://hexo.io/" target="_blank">Hexo</a></li>
      <li>theme  <a target="_blank" rel="noopener" href="https://github.com/zhwangart/hexo-theme-ocean">Ocean</a></li>
    </ul>
  </div>
</footer>
  </main>
  <aside class="sidebar">
    <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/hexo.svg" alt="思远程序"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/recommend">推荐</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/gallery">相册</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/favorites">收藏</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/about">关于</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link nav-item-search" title="搜索">
        <i class="fe fe-search"></i>
        搜索
      </a>
    </li>
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      <div class="totop" id="totop">
  <i class="fe fe-rocket"></i>
</div>
    </li>
    <li class="nav-item">
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="fe fe-feed"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
  </aside>
  
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/jquery.justifiedGallery.min.js"></script>


<script src="/js/lazyload.min.js"></script>


<script src="/js/busuanzi-2.3.pure.min.js"></script>



<script src="/fancybox/jquery.fancybox.min.js"></script>





<script src="/js/tocbot.min.js"></script>


<script>
  // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto',
  });
</script>



<script src="/js/ocean.js"></script>

</body>

</html>